package com.ceo.common.export;


import com.ceo.common.utils.StringKit;

import java.util.HashMap;
import java.util.Map;

/**
 * 枚举值格式化
 * @author chenjianglin
 *
 */
public class EnumFormater implements DataFormater
{
	private Map<String, String> enums;
	/**
	 * 格式化字符串
	 */
	public EnumFormater(Map<String, String> enums)
	{
		this.enums=enums==null?new HashMap<String, String>():enums;
	}
	public String formater(Object obj)
	{
		if(!StringKit.isBlank(obj))
		{
			StringBuffer sb=new StringBuffer("");
			for(String key:obj.toString().split(","))
			{
				sb.append(","+(enums.get(key)==null?key:enums.get(key)));
			}
			return sb.replace(0, 1, "").toString();
		}
		else 
			return "";
	}
}
